package com.mkyong.common;

import java.io.Serializable;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

@ManagedBean(name="app")
@ApplicationScoped
public class ApplicationBean implements Serializable {
	
	private String appName = "JSF 2.0 Demo";
	
	@Override
	public String toString() {
		return "ApplicationBean [appName=" + appName + ", appPath=" + appPath
				+ "]";
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

	public void setAppPath(String appPath) {
		this.appPath = appPath;
	}

	private String appPath = "";
	
	public String getAppPath() {
		String path1 = FacesContext.getCurrentInstance().getExternalContext().getRequestServletPath();
		String path2 = FacesContext.getCurrentInstance().getExternalContext().getRequestPathInfo();
		String path3 = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
		return path3;		
	}

}
